<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    <style>

    </style>
</head>

<body>
    <div id="app">
        <comp>
            <!-- 直接用num 他是全局app的 -->
            <!-- <button slot="btn">{{num}}</button> -->

            <button slot='btn' slot-scope="scope">{{scope.mynum}} -- {{scope.title}}</button>
        </comp>
    </div>
</body>

<template id="tmpl">
    <div>
        <h1>标题1</h1>
        <slot name="btn" :mynum="num" title="哈哈"></slot>
    </div>
</template>

<script>
    let comp = {
        template: '#tmpl',
        data() {
            return {
                num: 111
            }
        },
    }
    var vm = new Vue({
        el: '#app',
        data: {
            num: 222
        },
        components: {
            comp
        }
    })
</script>

</html>